#ifndef VISUALIZEPROCESS_H
#define VISUALIZEPROCESS_H
#include "reconstruct3d_global.h"
#include <QD3D/QD3DUtils.h>
#include <glm/glm.hpp>
#include "ProcessBase.hpp"


class RECONSTRUCT3D_EXPORT VisualizeProcess : public ProcessBase
{
public:
	VisualizeProcess (const ReconstructConfig& iConfig);
	~VisualizeProcess ();

	virtual void initialize ();
	virtual void clean ();

	void updateViewMat (const glm::mat4& m);
	void updateProjMat (const glm::mat4& m);

	void drawMesh (ID3D11Buffer *pVerticesDxBuf, UINT elemOffset,
			glm::vec4 color = glm::vec4 ());
	void drawVertices (ID3D11Buffer *pVerticesDxBuf, UINT elemOffset,
			UINT elemCount, glm::vec4 color = glm::vec4 ());
	void drawVertexPairs (ID3D11Buffer *pVertexPairsForVisualDxBuf);
	void drawCoord ();

private:
	CONST_STRUCT_BEGIN(MatrixConstVars)
		glm::vec4 color;
		glm::mat4 viewMatrix;
		glm::mat4 projectionMatrix;
	CONST_STRUCT_END
	CONST_STRUCT_BEGIN (MaterialConstVars)
	CONST_STRUCT_END

	ID3D11InputLayout *_pVertexDxLayout;
	ID3D11VertexShader *_pVisualizeVS;
	ID3D11GeometryShader* _p_visualizeGS;
	ID3D11PixelShader *_pVisualizePS;

	MatrixConstVars _matrixConstVars;
	MaterialConstVars _materialConstVars;
	ID3D11Buffer* _p_matrixDxConstBuf;
	ID3D11Buffer* _p_materialDxConstBuf;
	ID3D11Buffer* _p_coordVertexBuf;
	ID3D11Buffer* _p_meshIndexBuf;
	bool _isMatrixUploaded;
	uint _triangles;

	void _updateMatrixConstBuf ();
	void _updateMaterialConstBuf (glm::vec4 color);
};

#endif // VISUALIZEPROCESS_H
